home *** CD-ROM | disk | FTP | other *** search
/ Adventure Games / Adventure Games 1.iso / panic / panic.exe / panic.DXR / 00241.ls < prev    next >
Encoding:
Text File  |  1995-08-24  |  15.0 KB  |  404 lines

  1. global gSlowMachine, gDartSprite, gDartHandSprite, gHandAiming, gHandReleasing, gDart0, gDart1, gDart2, gDart3, gDart4, gDart5, gDart6, gDart7, gGreenBalloon, gGreenBalloonPopped, gOrangeBalloon, gOrangeBalloonPopped, cHotCursor, cGeneralCursor, gHot, gHotMask, gBalloonSprite, gDeedBalloon, gBalloonsPopped, gDarts, gTokens, gTokenSprite, gStartDarts
  2.  
  3. on playDarts
  4.   puppetSprite(gDartHandSprite, 1)
  5.   set userV to the mouseV
  6.   set userH to the mouseH
  7.   if userH < 128 then
  8.     if inside(point(userH, userV), rect(0, 362, 108, 384)) then
  9.       cursor([gHot, gHotMask])
  10.     else
  11.       cursor(200)
  12.     end if
  13.   end if
  14.   set userH to checkRange(userH, 128, 393)
  15.   set the locH of sprite gDartHandSprite to userH
  16.   updateStage()
  17.   if userV > 370 then
  18.     moveHandDown(384)
  19.     startTimer()
  20.     set gStartDarts to 1
  21.     go(the frame)
  22.     exit
  23.   else
  24.     if userV > 360 then
  25.       go(the frame)
  26.       exit
  27.     else
  28.       if gStartDarts <> 1 then
  29.         go(the frame)
  30.         exit
  31.       end if
  32.       if the timer < 150 then
  33.         if gDarts < 1 then
  34.           if gTokens = 0 then
  35.             loseGame()
  36.             exit
  37.           else
  38.             set gTokens to gTokens - 1
  39.             set gDarts to gDarts + 5
  40.             showTokens()
  41.           end if
  42.         end if
  43.         set gDarts to gDarts - 1
  44.         set throwDart to 1
  45.         set target to 0
  46.         delayFor(10)
  47.         set percentH to (userH - 128) * 1.0 / 275
  48.         set percentH to checkRange(percentH, 0.01, 1.0)
  49.         set destinationH to ((373 - 138) * percentH) + 138
  50.         set userV to the mouseV
  51.         set userV to checkRange(userV, 200, 360)
  52.         set percentV to (userV - 220) * 1.0 / 160
  53.         set percentV to checkRange(percentV, 0.01, 1.0)
  54.         set destinationV to ((322 - 65) * percentV) + 65
  55.         set destinationPoint to point(destinationH, destinationV)
  56.         repeat with x = gBalloonSprite to gBalloonSprite + 19
  57.           set locHx to the locH of sprite x
  58.           set locVx to the locV of sprite x
  59.           set checkRect to rect(the left of sprite x, the top of sprite x, the right of sprite x, the bottom of sprite x)
  60.           if inside(destinationPoint, checkRect) then
  61.             if (the castNum of sprite x = gGreenBalloonPopped) or (the castNum of sprite x = gOrangeBalloonPopped) then
  62.               exit repeat
  63.             end if
  64.             set checkRect to rect(locHx - 15, locVx - 15, locHx + 15, locVx + 15)
  65.             if inside(destinationPoint, checkRect) then
  66.               set target to x
  67.               set gBalloonsPopped to gBalloonsPopped + 1
  68.               set destinationPoint to point(locHx + random(5) - 10, locVx + random(5) - 10)
  69.               exit repeat
  70.             else
  71.               if destinationH < locHx then
  72.                 set destinationH to destinationH - 15
  73.               else
  74.                 set destinationH to destinationH + 17
  75.               end if
  76.               if destinationV < locVx then
  77.                 set destinationV to destinationV - 10
  78.               else
  79.                 set destinationV to destinationV + 10
  80.               end if
  81.               set destinationPoint to point(destinationH, destinationV)
  82.               exit repeat
  83.             end if
  84.             next repeat
  85.           end if
  86.         end repeat
  87.         if the locV of sprite gDartHandSprite > 351 then
  88.           repeat with x = the locV of sprite gDartHandSprite down to 351
  89.             set the locV of sprite gDartHandSprite to x
  90.             updateStage()
  91.             set x to x - 1
  92.           end repeat
  93.           set the locV of sprite gDartHandSprite to 351
  94.           updateStage()
  95.         end if
  96.         set userV to 315
  97.         set the castNum of sprite gDartHandSprite to gHandReleasing
  98.         updateStage()
  99.         activate(gDartSprite, gDart1, 1, 36, -5000, -5000, EMPTY, EMPTY, EMPTY)
  100.         set the backColor of sprite gDartSprite to 204
  101.         updateStage()
  102.         sound stop 1
  103.         puppetSound(0)
  104.         if target > 0 then
  105.           puppetSound("Balloon, pop")
  106.           updateStage()
  107.         else
  108.           puppetSound("Dart, miss")
  109.           updateStage()
  110.         end if
  111.         if (gSlowMachine = 1) or (programmersKey() = 1) then
  112.           updateDart(gDart1, userH, userV, destinationH, destinationV, 1.10000000000000009)
  113.           updateDart(gDart1, userH, userV, destinationH, destinationV, 1.20000000000000018)
  114.           updateDart(gDart2, userH, userV, destinationH, destinationV, 1.40000000000000013)
  115.           updateDart(gDart2, userH, userV, destinationH, destinationV, 1.70000000000000018)
  116.           updateDart(gDart3, userH, userV, destinationH, destinationV, 2.10000000000000009)
  117.           updateDart(gDart3, userH, userV, destinationH, destinationV, 2.60000000000000009)
  118.           updateDart(gDart4, userH, userV, destinationH, destinationV, 3.20000000000000018)
  119.           updateDart(gDart4, userH, userV, destinationH, destinationV, 3.90000000000000036)
  120.         else
  121.           updateDart(gDart1, userH, userV, destinationH, destinationV, 1.10000000000000009)
  122.           updateDart(gDart1, userH, userV, destinationH, destinationV, 1.20000000000000018)
  123.           updateDart(gDart1, userH, userV, destinationH, destinationV, 1.40000000000000013)
  124.           updateDart(gDart2, userH, userV, destinationH, destinationV, 1.70000000000000018)
  125.           updateDart(gDart2, userH, userV, destinationH, destinationV, 2.10000000000000009)
  126.           updateDart(gDart2, userH, userV, destinationH, destinationV, 2.60000000000000009)
  127.           updateDart(gDart3, userH, userV, destinationH, destinationV, 3.20000000000000018)
  128.           updateDart(gDart3, userH, userV, destinationH, destinationV, 3.90000000000000036)
  129.           updateDart(gDart3, userH, userV, destinationH, destinationV, 4.70000000000000018)
  130.           updateDart(gDart4, userH, userV, destinationH, destinationV, 5.60000000000000053)
  131.           updateDart(gDart4, userH, userV, destinationH, destinationV, 6.60000000000000053)
  132.           updateDart(gDart4, userH, userV, destinationH, destinationV, 7.70000000000000018)
  133.         end if
  134.         do("set the castNum of sprite gDartSprite=gDart" & random(3) + 4)
  135.         set the loc of sprite gDartSprite to point(destinationH, destinationV)
  136.         if gBalloonsPopped = gDeedBalloon then
  137.           set deedSprite to gDartHandSprite + 1
  138.           put target, the locH of sprite target, the locV of sprite target
  139.           set coords to adjustedCoords(the locH of sprite target, the locV of sprite target, -7, -12, 7, 12, 1)
  140.           set the visible of sprite deedSprite to 1
  141.           activate(deedSprite, "Parchment", 1, 36, -7, -12, "stretch to:", 7, 12)
  142.           set the backColor of sprite deedSprite to 204
  143.         end if
  144.         if target > 0 then
  145.           puppetSprite(target, 1)
  146.           if the castNum of sprite target = gGreenBalloon then
  147.             set the castNum of sprite target to gGreenBalloonPopped
  148.           else
  149.             if the castNum of sprite target = gOrangeBalloon then
  150.               set the castNum of sprite target to gOrangeBalloonPopped
  151.             end if
  152.           end if
  153.           updateStage()
  154.         else
  155.         end if
  156.         if gBalloonsPopped = gDeedBalloon then
  157.           winGame(target, deedSprite)
  158.           exit
  159.         else
  160.           set delayFor to the timer + 60
  161.           repeat while the timer < delayFor
  162.             moveHandAcross()
  163.           end repeat
  164.         end if
  165.         set the castNum of sprite gDartHandSprite to gHandAiming
  166.         repeat while the mouseV < 370
  167.           moveHandAcross()
  168.         end repeat
  169.       else
  170.         if the locV of sprite gDartHandSprite > 358 then
  171.           repeat with x = the locV of sprite gDartHandSprite down to 358
  172.             set the locV of sprite gDartHandSprite to x
  173.             updateStage()
  174.             set x to x - 1
  175.           end repeat
  176.           set the locV of sprite gDartHandSprite to 384
  177.           updateStage()
  178.         end if
  179.         startTimer()
  180.       end if
  181.     end if
  182.   end if
  183.   go(the frame)
  184. end
  185.  
  186. on fnc startPoint, endPoint, whichStep
  187.   if voidp(whichStep) then
  188.     set whichStep to 1
  189.   end if
  190.   if whichStep = 0 then
  191.     set whichStep to 1
  192.   end if
  193.   return endPoint - ((endPoint - startPoint) / whichStep)
  194. end
  195.  
  196. on updateDart whichDart, userH, userV, destinationH, destinationV, whichValue
  197.   set the castNum of sprite gDartSprite to whichDart
  198.   set the loc of sprite gDartSprite to point(fnc(userH, destinationH, whichValue), fnc(userV, destinationV, whichValue))
  199.   updateStage()
  200. end
  201.  
  202. on adjustedCoords targetH, targetV, h1, v1, h2, v2, whichStep
  203.   set h1 to fnc(h1 + targetH, 258, whichStep)
  204.   set h2 to fnc(h2 + targetH, 258, whichStep)
  205.   set v1 to fnc(v1 + targetV, 184, whichStep)
  206.   set v2 to fnc(v2 + targetV, 184, whichStep)
  207.   set newCoordinates to [h1, v1, h2, v2]
  208.   return newCoordinates
  209. end
  210.  
  211. on adjustedTokenCoords targetH, targetV, h1, v1, h2, v2, whichStep
  212.   set h1 to fnc(h1 + targetH, 305, whichStep)
  213.   set h2 to fnc(h2 + targetH, 305, whichStep)
  214.   set v1 to fnc(v1 + targetV, 170, whichStep)
  215.   set v2 to fnc(v2 + targetV, 170, whichStep)
  216.   set newCoordinates to [h1, v1, h2, v2]
  217.   return newCoordinates
  218. end
  219.  
  220. on findCoord pCenter, pTopLeft, pBottomRight
  221.   put getAt(pTopLeft, 1) - getAt(pCenter, 1) & ", " & getAt(pTopLeft, 2) - getAt(pCenter, 2) & ", " & getAt(pBottomRight, 1) - getAt(pCenter, 1) & ", " & getAt(pBottomRight, 2) - getAt(pCenter, 2)
  222. end
  223.  
  224. on winGame target, deedSprite
  225.   set gDeedBalloon to 0
  226.   delayFor(5)
  227.   set coords to adjustedCoords(the locH of sprite target, the locV of sprite target, -35, -39, 36, 38, 1)
  228.   spriteBox(deedSprite, getAt(coords, 1), getAt(coords, 2), getAt(coords, 3), getAt(coords, 4))
  229.   delayFor(5)
  230.   moveHandAcross()
  231.   set coords to adjustedCoords(the locH of sprite target, the locV of sprite target, -63, -65, 64, 65, 1.10000000000000009)
  232.   spriteBox(deedSprite, getAt(coords, 1), getAt(coords, 2), getAt(coords, 3), getAt(coords, 4))
  233.   delayFor(5)
  234.   moveHandAcross()
  235.   set coords to adjustedCoords(the locH of sprite target, the locV of sprite target, -92, -91, 92, 91, 1.30000000000000004)
  236.   spriteBox(deedSprite, getAt(coords, 1), getAt(coords, 2), getAt(coords, 3), getAt(coords, 4))
  237.   delayFor(5)
  238.   moveHandAcross()
  239.   set coords to adjustedCoords(the locH of sprite target, the locV of sprite target, -120, -118, 120, 117, 1.40000000000000013, 1.70000000000000018)
  240.   spriteBox(deedSprite, getAt(coords, 1), getAt(coords, 2), getAt(coords, 3), getAt(coords, 4))
  241.   delayFor(5)
  242.   moveHandAcross()
  243.   set the stretch of sprite deedSprite to 0
  244.   set the loc of sprite deedSprite to point(258, 184)
  245.   delayFor(5)
  246.   moveHandDown(420)
  247.   set the locV of sprite gDartHandSprite to -5000
  248.   cursor(-1)
  249.   set flash1 to gDartHandSprite - 3
  250.   set flash2 to gDartHandSprite - 2
  251.   activate(flash1, "flash1", 1, 0, 105, -5000, EMPTY, EMPTY, EMPTY)
  252.   activate(flash2, "flash2", 1, 0, 406, -5000, EMPTY, EMPTY, EMPTY)
  253.   puppetSound("Win Game")
  254.   deactivate([gDartHandSprite + 1])
  255.   go("deed")
  256.   repeat while the soundBusy of 1
  257.     repeat with x = gBalloonSprite to gBalloonSprite + 19
  258.       flashBalloons(x, flash1, flash2, 193, -5000)
  259.       flashBalloons(x, flash1, flash2, -5000, 203)
  260.     end repeat
  261.   end repeat
  262.   deactivate([flash1, flash2])
  263.   puppetSound(0)
  264.   updateStage()
  265. end
  266.  
  267. on flashBalloons x, flash1, flash2, locV1, locV2
  268.   if the castNum of sprite x = gGreenBalloon then
  269.     set the castNum of sprite x to gOrangeBalloon
  270.   else
  271.     if the castNum of sprite x = gOrangeBalloon then
  272.       set the castNum of sprite x to gGreenBalloon
  273.     end if
  274.   end if
  275.   set the locV of sprite flash1 to locV1
  276.   set the locV of sprite flash2 to locV2
  277.   updateStage()
  278.   delay(30)
  279. end
  280.  
  281. on loseGame
  282.   puppetSound("Lose Game")
  283.   moveHandDown(420)
  284.   set the locV of sprite gDartHandSprite to -5000
  285.   updateStage()
  286.   cursor(-1)
  287.   delayFor(120)
  288.   scene2()
  289. end
  290.  
  291. on scene2
  292.   set gStartDarts to 0
  293.   set gBalloonsPopped to 0
  294.   if random(3) = 1 then
  295.     set gDeedBalloon to random(4) + 1
  296.   else
  297.     set gDeedBalloon to random(15) + 5
  298.   end if
  299.   puppetSound(0)
  300.   setProp(1, 48, "puppet", 0)
  301.   setProp(1, 48, "visibility", 0)
  302.   go("Scene 2")
  303. end
  304.  
  305. on hideTokens
  306.   activate(gTokenSprite, "QDBox", 16, 36, 454, 0, "stretch to:", 512, 384)
  307.   set the backColor of sprite gTokenSprite to the foreColor of sprite gTokenSprite
  308.   updateStage()
  309. end
  310.  
  311. on showTokens dontHide, fortune
  312.   if dontHide <> 1 then
  313.     hideTokens()
  314.   end if
  315.   set the trails of sprite gTokenSprite to 1
  316.   repeat with x = 1 to gTokens
  317.     activate(gTokenSprite, "Token", 1, 8, 483, 371 - (x * 10), EMPTY, EMPTY, EMPTY)
  318.     updateStage()
  319.     if fortune = "Fortune" then
  320.       if x = (gTokens - 1) then
  321.         if gTokens > 1 then
  322.           set the trails of sprite (gTokenSprite - 2) to 1
  323.           activate(gTokenSprite - 2, "Token", 1, 8, 483, 371 - (gTokens * 10) + 10, EMPTY, EMPTY, EMPTY)
  324.           if gTokens > 2 then
  325.             activate(gTokenSprite - 1, "TokenPatch", 1, 0, 457, 371 - (gTokens * 10) + 18, EMPTY, EMPTY, EMPTY)
  326.           end if
  327.         end if
  328.         updateStage()
  329.       end if
  330.     end if
  331.   end repeat
  332.   if fortune <> "Fortune" then
  333.     deactivate([gTokenSprite])
  334.   end if
  335.   set the trails of sprite gTokenSprite to 0
  336.   updateStage()
  337. end
  338.  
  339. on payFortuneTeller
  340.   if gTokens < 1 then
  341.     exit
  342.   end if
  343.   set gTokens to gTokens - 1
  344.   set tokenH to 320
  345.   set tokenV to 180
  346.   set coords to adjustedTokenCoords(tokenH, tokenV, -28, -21, 28, 22, 1)
  347.   spriteBox(gTokenSprite, getAt(coords, 1), getAt(coords, 2), getAt(coords, 3), getAt(coords, 4))
  348.   delayFor(5)
  349.   moveHandAcross()
  350.   set coords to adjustedTokenCoords(tokenH, tokenV, -22, -17, 22, 17, 1.10000000000000009)
  351.   spriteBox(gTokenSprite, getAt(coords, 1), getAt(coords, 2), getAt(coords, 3), getAt(coords, 4))
  352.   delayFor(5)
  353.   moveHandAcross()
  354.   set coords to adjustedTokenCoords(tokenH, tokenV, -12, -9, 12, 10, 1.20000000000000018)
  355.   spriteBox(gTokenSprite, getAt(coords, 1), getAt(coords, 2), getAt(coords, 3), getAt(coords, 4))
  356.   delayFor(5)
  357.   moveHandAcross()
  358.   set coords to adjustedTokenCoords(tokenH, tokenV, -7, -5, 6, 6, 1.40000000000000013)
  359.   spriteBox(gTokenSprite, getAt(coords, 1), getAt(coords, 2), getAt(coords, 3), getAt(coords, 4))
  360.   delayFor(5)
  361.   moveHandAcross()
  362.   set coords to adjustedTokenCoords(tokenH, tokenV, -6, -4, 5, 5, 1.80000000000000004)
  363.   spriteBox(gTokenSprite, getAt(coords, 1), getAt(coords, 2), getAt(coords, 3), getAt(coords, 4))
  364.   delayFor(5)
  365.   set the locV of sprite gTokenSprite to -5000
  366.   updateStage()
  367.   delayFor(60)
  368.   deactivate([gTokenSprite - 2, gTokenSprite - 1, gTokenSprite])
  369.   set the trails of sprite (gTokenSprite - 2) to 0
  370.   set the trails of sprite (gTokenSprite - 1) to 0
  371.   set the trails of sprite gTokenSprite to 0
  372.   hideTokens()
  373.   go("Jump")
  374. end
  375.  
  376. on addToken whichSprite
  377.   set the locV of sprite (whichSprite - 1) to -5000
  378.   set the locV of sprite whichSprite to -5000
  379.   set the locV of sprite (whichSprite + 1) to -5000
  380.   updateStage()
  381.   set gTokens to gTokens + 1
  382.   showTokens(1)
  383.   playSound("Token")
  384.   go(the frame + 1)
  385. end
  386.  
  387. on moveHandAcross
  388.   set userH to checkRange(the mouseH, 128, 393)
  389.   set the loc of sprite gDartHandSprite to point(userH, 358)
  390.   updateStage()
  391. end
  392.  
  393. on moveHandDown newV
  394.   if the locV of sprite gDartHandSprite < newV then
  395.     repeat with x = the locV of sprite gDartHandSprite to newV
  396.       set the locV of sprite gDartHandSprite to x
  397.       updateStage()
  398.       set x to x + 1
  399.     end repeat
  400.     set the locV of sprite gDartHandSprite to newV
  401.     updateStage()
  402.   end if
  403. end
  404.